import { createRouter,createWebHistory }  from "vue-router";

import Home from "../views/Home.vue"
import Layout from '../views/Layout.vue'
import exampleJson  from './example';

let exampleRoutes = []
exampleJson.forEach(item=>{
  exampleRoutes.push({
    path:'/'+item.component.toLocaleLowerCase(),
    component:()=> import('../views/'+item.component+'.vue'),
    meta:{
      title:item.title
    }
  })
})



const routes = [
  {
    path:"/",
    name:'Home',
    component:Home,
  },
  {
    path: "/layout",
    name: "Layout",
    component: Layout,
    children:[
      ...exampleRoutes
    ]
  }  
];

const router = createRouter({
  history: createWebHistory("/"),
  routes,
});

export default router;
